from appium.webdriver.common.mobileby import MobileBy

from AppWorkWxin.PO.addmemberpage import AddMemberPage
from AppWorkWxin.PO.basepage import  BasePage


class ContactPage(BasePage):

    def get_title(self):
        # ele_title = self.find(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/hc0' and @text contains('消息')]")
        ele_title = self.driver.find_element_by_android_uiautomator(
            'new UiSelector().text("添加成员")')
        
        print(ele_title.text)
        return  ele_title.text

    def get_memberlist(self, membername):
        """
        获取企业通讯录成员
        :return: 成员姓名
        """
        ele_member = self.driver.find_element_by_android_uiautomator(
            f'new UiSelector().text("{membername}")')
        
        return ele_member.text
        
        
    def goto_AddmemberPage(self):
        """
        点击添加成员，进入添加成员页面后当前活动页已改变
        切换测试页面
        :return: 添加成员页面
        """
        # 点击添加成员
        self.driver.find_element_by_android_uiautomator(
            'new UiSelector().text("添加成员")').click()
        
        # .friends.controller.MemberInviteMenuActivity
        # 返回添加成员页面
        # self.desired_capabilities["appActivity"] = ".friends.controller.MemberInviteMenuActivity"
        return AddMemberPage(self.driver)